package com.ruoyi.web.controller.retirement;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.retirement.domain.RetirementConfig;
import com.ruoyi.retirement.service.IRetirementConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 参数配置Controller
 * 
 * @author 曹旭
 * @date 2025-09-04
 */
@RestController
@RequestMapping("/retirement/retirementConfig")
public class RetirementConfigController extends BaseController
{
    @Autowired
    private IRetirementConfigService retirementConfigService;

    /**
     * 查询参数配置列表
     */
    @PreAuthorize("@ss.hasPermi('retirement:retirementConfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(RetirementConfig retirementConfig)
    {
        startPage();
        List<RetirementConfig> list = retirementConfigService.selectRetirementConfigList(retirementConfig);
        return getDataTable(list);
    }

    /**
     * 导出参数配置列表
     */
    @PreAuthorize("@ss.hasPermi('retirement:retirementConfig:export')")
    @Log(title = "参数配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RetirementConfig retirementConfig)
    {
        List<RetirementConfig> list = retirementConfigService.selectRetirementConfigList(retirementConfig);
        ExcelUtil<RetirementConfig> util = new ExcelUtil<RetirementConfig>(RetirementConfig.class);
        util.exportExcel(response, list, "参数配置数据");
    }

    /**
     * 获取参数配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('retirement:retirementConfig:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(retirementConfigService.selectRetirementConfigById(id));
    }

    /**
     * 新增参数配置
     */
    @PreAuthorize("@ss.hasPermi('retirement:retirementConfig:add')")
    @Log(title = "参数配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RetirementConfig retirementConfig)
    {
        return toAjax(retirementConfigService.insertRetirementConfig(retirementConfig));
    }

    /**
     * 修改参数配置
     */
    @PreAuthorize("@ss.hasPermi('retirement:retirementConfig:edit')")
    @Log(title = "参数配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RetirementConfig retirementConfig)
    {
        return toAjax(retirementConfigService.updateRetirementConfig(retirementConfig));
    }

    /**
     * 删除参数配置
     */
    @PreAuthorize("@ss.hasPermi('retirement:retirementConfig:remove')")
    @Log(title = "参数配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(retirementConfigService.deleteRetirementConfigByIds(ids));
    }
}
